#include <stdio.h>
#include <iostream>
#include "Student.cpp"

using namespace std;

listaSt M;

void init()
	{
	Student A; 
	char nume[10];
	int b;
	std::cout<<"\nSe va adauga un numar maxim de 30 de studenti, pana la intalnirea caracterului '*' !\n\n\n";
	while(strcmp(nume,"*")!=0)
		{
		std::cout<<"\nIntroduceti numele studentului : ";cin>>nume;
			if(strcmp(nume,"*")!=0)
				{
				A.setNume(nume);
				std::cout<<"\nIntroduceti prenumele studentului : ";cin>>nume;
				A.setPren(nume);
				std::cout<<"\nIntroduceti numarul matricol al studentului : ";std::cin>>b;
				A.setNrMat(b);
				M.adauga(A);
				}
		}
	}
void adauga()
	{
	Student A; 
	char nume[10];
	int b;
	std::cout<<"\nIntroduceti numele studentului : ";cin>>nume;
	A.setNume(nume);
	std::cout<<"\nIntroduceti prenumele studentului : ";cin>>nume;
	A.setPren(nume);
	std::cout<<"\nIntroduceti numarul matricol al studentului : ";std::cin>>b;
	A.setNrMat(b);
	M.adauga(A);	
	}
int meniu()
	{
	int n;
	std::cout<<"\n\tOperatii asupra listei cu inregistrari ale studentilor : \n\n\n";
	std::cout<<"\t\t--------------------"<<endl;
	std::cout<<"\t\t| 1. Creare        |"<<endl;
	std::cout<<"\t\t| 2. Vizualizare   |"<<endl;
	std::cout<<"\t\t| 3. Adaugare      |"<<endl;
	std::cout<<"\t\t| 4. Modificare    |"<<endl;
	std::cout<<"\t\t| 5. Stergere      |"<<endl;
	std::cout<<"\t\t| 6. Cautare       |"<<endl;
	std::cout<<"\t\t| 7. Iesire        |"<<endl;
	std::cout<<"\t\t|------------------|"<<endl;
	std::cout<<"Introduceti optiunea : ";std::cin>>n;	
	return n;
	}
void sterge()
	{
		int n;
		std::cout<<"\n\ntOperatii asupra listei cu inregistrari ale studentilor : \n\n\n";
		std::cout<<"\t\t-------------------------------------"<<endl;
		std::cout<<"\t\t| 1.  Stergere dupa nume/prenume    |"<<endl;
		std::cout<<"\t\t| 2.  Stergere dupa  numar matricol |"<<endl;
		std::cout<<"\t\t| 3.  Iesire                        |"<<endl;
		std::cout<<"\t\t|-----------------------------------|"<<endl<<endl;
		std::cout<<"Introduceti optiunea : ";cin>>n;	
		if(n==1)
			{
			char s[10];
			std::cout<<"\nIntroduceti numele : ";std::cin>>s;
			M.sterge(s);	
			}	
		if(n==2)
			{
			int s;
			std::cout<<"\nIntroduceti numele : ";std::cin>>s;
			M.sterge(s);	
			}
	}
void modifica()
	{
	int n;
	std::cout<<"\t\t--------------------------------"<<endl;
	std::cout<<"\t\t| 1.  Modificare nume            |"<<endl;
	std::cout<<"\t\t| 2.  Modificare prenume         |"<<endl;
	std::cout<<"\t\t| 3.  Modificare numar matricol  |"<<endl;
	std::cout<<"\t\t| 4.  Iesire                     |"<<endl;
	std::cout<<"\t\t|--------------------------------|"<<endl<<endl;
	std::cout<<"Introduceti optiunea : ";cin>>n;	
	switch(n)
		{
		case 1:M.modificaNume();break;
		case 2:M.modificaPren();break;
		case 3:M.modificaNr();break;
		case 4:break;
		}	
  }
void cautanume()
	{
	char s[10];
	std::cout<<"\nIntroduceti numele cautat : ";cin>>s;
	M.cauta(s);	
	}
void cautanumar()
	{
	int s;
	std::cout<<"\nIntroduceti numarul matrico al elevului cautat : ";cin>>s;
	M.cauta(s);	
	}
void cauta()
	{
	int n;
	std::cout<<"\t\t-----------------------------------"<<endl;
	std::cout<<"\t\t| 1.  Cauta dupa nume/prenume     |"<<endl;
	std::cout<<"\t\t| 2.  Cauta dupa nr. matricol     |"<<endl;
	std::cout<<"\t\t| 3.  Iesire                      |"<<endl;
	std::cout<<"\t\t|---------------------------------|"<<endl<<endl;
	std::cout<<"Introduceti optiunea : ";std::cin>>n;	
	switch(n)
		{
		case 1:cautanume();break;
		case 2:cautanumar();break;
		case 3:break;
		}
	}
void afiseaza()
	{
	std::cout<<"\n\n\n\n"<<M;	
	}
int main()
	{
	int n;
	do
		{
		n=meniu();
	  switch(n)
			{
			case 1:init();break;
			case 2:afiseaza();break;
			case 3:adauga();break;
			case 4:modifica();break;
			case 5:sterge();break;
			case 6:cauta();break;
			case 7:break;
			default : std::cout<<"\nOptiunea introdusa nu exista !!\n";
			}
		}
	while(n!=7);
	return 0;	
	}

	
